/**
 * @file    rga_converter.hpp
 * @brief   rga功能类定义
 * @author  Haozhong Xu
 * @date    2025-05-27
 * @version 1.0
 * 
 * @note    定义RGA功能类，提供对外调用函数
 */
#ifndef RGA_CONVERTER_HPP
#define RGA_CONVERTER_HPP

#include <string>
#include <cstdint>
#include "rga/im2d.h"
#include "RgaUtils.h"
#include "allocator/include/dma_alloc.h"


/**
 * @class RGAConverter
 * @brief RGA 功能类，申请dma内存并提供硬件加速处理功能
 *
 * 用于将dma中连续物理内存中的图像数据进行色域转换，
 * 图像反转，resize等操作
 */
class RGAConverter {
public:
    // 初始化函数，申请连续dma内存
    RGAConverter(int width, int height);
    ~RGAConverter();

    // 对外提供的功能类函数，进行色域转换
    bool ConvertYUYVToRGB(const uint8_t* yuyv_data, size_t size);
    const uint8_t* GetRGBData() const;
    size_t GetRGBDataSize() const;

private:
    int _width;
    int _height;
    int _src_size;
    int _dst_size;

    int _src_fd = -1;
    int _dst_fd = -1;
    uint8_t* _src_buf = nullptr;
    uint8_t* _dst_buf = nullptr;

    rga_buffer_handle_t _src_handle = 0;
    rga_buffer_handle_t _dst_handle = 0;

    rga_buffer_t _src_img = {};
    rga_buffer_t _dst_img = {};
};

#endif // RGA_CONVERTER_HPP
